<template>
  <BasicModal
    @register="register"
    title="设置资料上传终止时间"
    :okButtonProps="{ disabled: false }"
    @ok="upTimeLast"
  >
    <DatePicker
      v-model:value="expirationTime"
      format="YYYY-MM-DD HH:mm:ss"
      placeholder="有效期"
      valueFormat="YYYY-MM-DD HH:mm:ss"
      :showTime="{ defaultValue: dateUtil('00:00:00', 'HH:mm:ss') }"
      :disabled-date="disabledDate"
    />
  </BasicModal>
</template>
<script lang="ts">
  import { defineComponent, ref } from 'vue';
  // import { Moment } from 'moment';
  import { DatePicker } from 'ant-design-vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import { dateUtil } from '/@/utils/dateUtil';
  import { ExpirationTime } from '/@/api/basic/qimo/index';
  import { number } from 'vue-types';
  export default defineComponent({
    components: { BasicModal, DatePicker },
    setup() {
      let otherIds: any = ref();
      const [register, { closeModal, setModalProps }] = useModalInner((data) => {
        otherIds.value = { ...data?.arr };
      });
      const disabledDate = (current) => {
        return current && current < dateUtil().endOf('day');
      };
      const expirationTime: any = ref();

      async function upTimeLast() {
        const ass = expirationTime.value.slice(0, 4);
        const arr = {
          expirationTime: expirationTime.value,
          targetYear: ass,
          otherId: '',
        };
        const result = await ExpirationTime(arr);
        closeModal();
        return result;
      }
      return {
        register,
        dateUtil,
        closeModal,
        disabledDate,
        expirationTime,
        upTimeLast,
        setModalProps: () => {
          setModalProps({ title: '设置资料上传终止时间' });
        },
      };
    },
  });
</script>
